﻿using ET.CommonLibrary;
using ET.Score.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ET.HeartBeat.SharedLibrary
{
    /// <summary>
    /// 简易wcf回调对象，使用事件注册的方式接受消息
    /// </summary>
    public class HeartBeatCallBack : IHeartBeatCallback
    {

        public event EventHandler<GeneralEventArgs<ArgumentBase<string>>> MessageReceived;
        #region IHeartBeatCallBack 成员

        public void OnMessageReceived(ArgumentBase<string> arg)
        {
            InternalOnMessageReceived(arg);
        }
        /// <summary>
        /// 收到新的回调消息时，会触发该方法
        /// </summary>
        /// <param name="arg"></param>
        protected virtual void InternalOnMessageReceived(ArgumentBase<string> arg)
        {
            var handler = MessageReceived;
            if (handler != null)
                handler(this, GeneralEventArgs.Create(arg));
        }
        #endregion
    }
}
